package com.example.validation.controller;


import com.example.validation.config.ValidateGroup;
import com.example.validation.entity.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@RestController
public class UserController {


    /**默认校验
     * @param user
     * @return
     */
    @GetMapping("/default")
    public Object defaultvalidate(@Validated User user) {
        return "ok";
    }

    /**分组校验
     * @param user
     * @return
     */
    @GetMapping("/group")
    public Object group(@Validated(ValidateGroup.insert.class) User user) {
        return "ok";
    }

}
